#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "aut.h"
#include <stdlib.h>
#include <string.h>
#include "patient0.h"



void on_Directeur_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
GtkWidget *head_secu;
GtkWidget *log_mdp;

head_secu=lookup_widget(objet_graphique, "head_secu");
gtk_widget_hide(head_secu);

log_mdp = create_log_mdp ();
gtk_widget_show (log_mdp);


}


void on_security_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
GtkWidget *head_secu;
GtkWidget *log_mdp2;

head_secu=lookup_widget(objet_graphique, "head_secu");
gtk_widget_hide(head_secu);

log_mdp2 = create_log_mdp2 ();
gtk_widget_show (log_mdp2);
}


void on_quit1_clicked (GtkWidget *objet_graphique,gpointer user_data)
{gtk_main_quit();
}


void on_ok1_clicked (GtkWidget *objet_graphique,gpointer user_data)
{char log[31],mdp[31];
int test;
char chemin[] =
"/home/khalilov007/projet-programmation-c-2014-esp-read-only/project1/src/info_head.txt";
GtkWidget *login1;//saisie graphique du login
GtkWidget *mdp1;//saisie graphique du prenom

login1 = lookup_widget(objet_graphique, "login1");
mdp1 = lookup_widget(objet_graphique, "mdp1");
//copie de login1 vers log
strcpy(log,gtk_entry_get_text(GTK_ENTRY(login1)));
///copie de mdp1 vers mdp
strcpy(mdp,gtk_entry_get_text(GTK_ENTRY(mdp1)));
test=verif_fheadmaster1(chemin,log,mdp);
if (test==1)
{
GtkWidget *log_mdp;
GtkWidget *pat_perso;

log_mdp=lookup_widget(objet_graphique, "log_mdp");
gtk_widget_hide(log_mdp);

pat_perso = create_pat_perso ();
gtk_widget_show (pat_perso);
}
else gtk_main_quit();


}


void on_patient_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *pat_perso;

pat_perso = lookup_widget(objet_graphique, "pat_perso");
gtk_widget_hide(pat_perso);

window1 = create_window1();
gtk_widget_show (window1);
}


void
on_personnel_clicked                   (GtkButton       *button,
                                        gpointer         user_data)
{

}


void on_modif_head_clicked(GtkWidget *objet_graphique,gpointer user_data)
{
GtkWidget *pat_perso;
GtkWidget *modifh;

pat_perso=lookup_widget(objet_graphique, "pat_perso");
gtk_widget_hide(pat_perso);

modifh = create_modifh ();
gtk_widget_show (modifh);
}


void on_quit3_clicked  (GtkWidget *objet_graphique,gpointer user_data)
{

GtkWidget *pat_perso;
GtkWidget *head_secu;

pat_perso=lookup_widget(objet_graphique, "pat_perso");
gtk_widget_hide(pat_perso);

head_secu = create_head_secu ();
gtk_widget_show (head_secu);

}


void on_parcours_clicked(GtkButton *button,gpointer user_data)
{

}


void on_capteur_clicked(GtkButton *button, gpointer user_data)
{

}


void on_modif2_clicked (GtkWidget *objet_graphique,gpointer user_data)
{

GtkWidget *par_capt;
GtkWidget *modifs;

par_capt=lookup_widget(objet_graphique, "par_capt");
gtk_widget_hide(par_capt);

modifs = create_modifs ();
gtk_widget_show (modifs);

}


void on_quit4_clicked (GtkWidget *objet_graphique,gpointer user_data)
{
GtkWidget *par_capt;
GtkWidget *head_secu;

par_capt=lookup_widget(objet_graphique, "par_capt");
gtk_widget_hide(par_capt);

head_secu = create_head_secu ();
gtk_widget_show (head_secu);
}


void on_ok2_clicked (GtkWidget *objet_graphique,gpointer user_data)
{char log[31],mdp[31];
int test;
char chemin[] =
"/home/khalilov007/projet-programmation-c-2014-esp-read-only/project1/src/info_security.txt";

GtkWidget *login2;//saisie graphique du login
GtkWidget *mdp2;//saisie graphique du prenom

login2 = lookup_widget(objet_graphique, "login2");
mdp2 = lookup_widget(objet_graphique, "mdp2");
//copie de login1 vers log
strcpy(log,gtk_entry_get_text(GTK_ENTRY(login2)));
///copie de mdp1 vers mdp
strcpy(mdp,gtk_entry_get_text(GTK_ENTRY(mdp2)));
test=verif_fheadmaster1(chemin,log,mdp);
if (test==1)
{
GtkWidget *log_mdp2;
GtkWidget *par_capt;

log_mdp2=lookup_widget(objet_graphique, "log_mdp2");
gtk_widget_hide(log_mdp2);

par_capt = create_par_capt ();
gtk_widget_show (par_capt);
}
else gtk_main_quit();


}


void on_ok3_clicked  (GtkWidget *objet_graphique,gpointer user_data)
{
char log[100],mdp[100];
int test;
char chemin[] =
"/home/khalilov007/projet-programmation-c-2014-esp-read-only/project1/src/info_head.txt";
GtkWidget *new_log0;//saisie graphique du login
GtkWidget *new_mdp0;//saisie graphique du prenom

new_log0 = lookup_widget(objet_graphique, "new_log0");
new_mdp0 = lookup_widget(objet_graphique, "new_mdp0");
//copie de login1 vers log
strcpy(log,gtk_entry_get_text(GTK_ENTRY(new_log0)));
///copie de mdp1 vers mdp
strcpy(mdp,gtk_entry_get_text(GTK_ENTRY(new_mdp0)));
modif_fsecurity0(chemin,log,mdp);

GtkWidget *modifh;
GtkWidget *pat_perso;

modifh=lookup_widget(objet_graphique, "modifh");
gtk_widget_hide(modifh);

pat_perso = create_pat_perso ();
gtk_widget_show (pat_perso);

}



void on_ok4_clicked   (GtkWidget *objet_graphique,gpointer user_data)
{
char log[100],mdp[100];
int test;
char chemin[] = "/home/hedi/Projects/project1/src/info_security.txt";
GtkWidget *new_log1;//saisie graphique du login
GtkWidget *new_mdp1;//saisie graphique du prenom

new_log1 = lookup_widget(objet_graphique, "new_log1");
new_mdp1 = lookup_widget(objet_graphique, "new_mdp1");
//copie de login1 vers log
strcpy(log,gtk_entry_get_text(GTK_ENTRY(new_log1)));
///copie de mdp1 vers mdp
strcpy(mdp,gtk_entry_get_text(GTK_ENTRY(new_mdp1)));
modif_fsecurity0(chemin,log,mdp);

GtkWidget *modifs;
GtkWidget *par_capt;

modifs=lookup_widget(objet_graphique, "modifs");
gtk_widget_hide(modifs);

par_capt = create_par_capt ();
gtk_widget_show (par_capt);

}



void on_button1_clicked(Gtk *objet_graphique, gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window2;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window2 = create_window2 ();
gtk_widget_show (window2);

}


void on_button9_clicked(GtkButton *button, gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window2;

window2=lookup_widget(objet_graphique, "window2");
gtk_widget_hide(window2);

window1 = create_window1 ();
gtk_widget_show (window1);
}


void on_button10_clicked(GtkButton *button, gpointer user_data)
{
patient p;
char message[100];
GtkWidget *entry1;
GtkWidget *entry2;
GtkWidget *entry3;
GtkWidget *entry4;
GtkWidget *entry5;
GtkWidget *entry6;
GtkWidget *entry7;
GtkWidget *entry8;
GtkWidget *entry9;
GtkWidget *entry10;


entry1 = lookup_widget(objet_graphique,"entry1");
entry2 = lookup_widget(objet_graphique,"entry2");
entry3 = lookup_widget(objet_graphique,"entry3");
entry4 = lookup_widget(objet_graphique,"entry4");
entry5 = lookup_widget(objet_graphique,"entry5");
entry6 = lookup_widget(objet_graphique,"entry6");
entry7 = lookup_widget(objet_graphique,"entry7");
entry8 = lookup_widget(objet_graphique,"entry8");
entry9 = lookup_widget(objet_graphique,"entry9");
entry10 = lookup_widget(objet_graphique,"entry10");

//copie de la chaine reçue vers p
strcpy(p.nom, gtk_entry_get_text(GTK_ENTRY(entry1)));
strcpy(p.prenom, gtk_entry_get_text(GTK_ENTRY(entry2)));
strcpy(p.sexe, gtk_entry_get_text(GTK_ENTRY(entry3)));
strcpy(p.etat, gtk_entry_get_text(GTK_ENTRY(entry4)));
strcpy(p.identifiant, gtk_entry_get_text(GTK_ENTRY(entry5)));
p.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry6)));
p.cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry7)));
p.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry6)));
p.jour = atoi(gtk_entry_get_text(GTK_ENTRY(entry7)));
p.mois = atoi(gtk_entry_get_text(GTK_ENTRY(entry8)));
p.annee = atoi(gtk_entry_get_text(GTK_ENTRY(entry9)));
strcpy(p.date_sortie, gtk_entry_get_text(GTK_ENTRY(entry10)));

ajout_patient(p);
GtkWidget *label27;
label27 = lookup_widget(objet_graphique, "label27");
strcpy(message,"enregistrée !");
sprintf(message,"%s",message);
gtk_label_set_text(GTK_LABEL(label27), message);
}


void on_button11_clicked(GtkButton *button, gpointer user_data)
{

}


void on_button12_clicked(GtkButton *button, gpointer user_data)
{

}


void on_button13_clicked(GtkButton *button, gpointer user_data)
{

}


void on_button14_clicked(GtkButton *button, gpointer user_data)
{

}


void on_button15_clicked(GtkButton *button, gpointer user_data)
{

}


void on_button16_clicked(GtkButton *objet_graphique, gpointer user_data)
{


}


void on_button17_clicked(GtkButton *objet_graphique,gpointer user_data)
{

}


void on_button2_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window3;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window3 = create_window3 ();
gtk_widget_show (window3);


}


void on_button3_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window4;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window4 = create_window4 ();
gtk_widget_show (window4);
}


void on_button4_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window5;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window5 = create_window5 ();
gtk_widget_show (window5);
}



void on_button5_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window6;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window6 = create_window6 ();
gtk_widget_show (window6);
}



void on_button6_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window7;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window7 = create_window7 ();
gtk_widget_show (window7);
}



void on_button7_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *window8;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

window8 = create_window8 ();
gtk_widget_show (window8);
}




void on_button8_clicked(GtkButton *objet_graphique,gpointer user_data)
{
GtkWidget *window1;
GtkWidget *pat_perso;

window1=lookup_widget(objet_graphique, "window1");
gtk_widget_hide(window1);

pat_perso = create_pat_perso ();
gtk_widget_show (pat_perso);
}

